<template>
    <div>TEST</div>
</template>

<script lang="ts">
    import {Vue} from 'vue-property-decorator'
    import medicineService from '@/phr/service/medicine/MedicineService'
    import hospitalService from '@/phr/service/hospital/HospitalService'
    import appointmentService from '@/phr/service/hospital/AppointmentService'
    import bmiService from '@/phr/service/bmi/BmiService'

    /**
     * 测试药品相关的API
     */
    function testMedicineApi(){
        console.log("测试搜索药品API开始");
        medicineService.searchMedicine("感冒",1)
            .then(res=>{
                console.log("测试搜索药品API完成");
                console.log(res);
            });
        console.log("测试药品详情信息API开始");
        medicineService.getMedicineDetail(100)
            .then(res=>{
                console.log("测试药品详情API成功");
                console.log(res)
            })
    }

    /**
     * 测试医院相关的API
     */
    function testHospitalApi(){
        console.log("测试医院API开始");
        console.log("测试搜索医院API开始");
        hospitalService.searchHospital("广东省","广州市","天河区",1)
                        .then(res=>{
                            console.log("测试搜索医院API完成");
                            console.log(res)
                        });
        console.log("测试搜索医院详情API开始");
        hospitalService.getHospitalDetail(1234)
                        .then(res=>{
                            console.log("测试搜索医院详情API完成");
                            console.log(res)
                        })
    }

    /**
     * 测试挂号相关的API
     */
    function testAppointmentApi() {
        console.log("测试自助挂号API开始");
        console.log("获取挂号历史API开始");
        appointmentService.queryAppointmentHistory()
            .then(res=>{
                console.log("获取挂号历史API完成");
                console.log(res);
            });
        //6420是中山三院的ID，嘻嘻
        console.log("自助挂号API开始");
        appointmentService.doAppointment(6420,"全科","张家嘉","2018-08-09")
            .then(res=>{
                console.log("自助挂号API完成");
                console.log(res)
            })
    }

    /**
     * 测试BMI相关API（注意，要先登录设置token）
     */
    function testBmiApi() {
        console.log("测试BMI开始");
        bmiService.getBmiData()
            .then(res=>{
                console.log("获取当前BMI数据完成");
                console.log(res)
            });
        bmiService.updateHeight(178)
            .then(res=>{
                console.log("更新身高完成");
                console.log(res)
            });
        bmiService.addWeight(66.9)
            .then(res=>{
                console.log("更新体重成功");
                console.log(res)
            });
        bmiService.addWeight(67.9,"2015-06-01T15:22:11")
            .then(res=>{
                console.log("更新体重完成（指定时间）");
                console.log(res)
            })

    }

    export default Vue.extend({
        name: "TestApi",
        mounted:function(){
            console.log("测试开始");
            //testBmiApi();
            //testMedicineApi();
            //testHospitalApi();
            //testAppointmentApi()
        }
    })
</script>

<style scoped>

</style>